﻿@model Epi.Web.MVC.Models.UserOrgModel
@{
    ViewBag.Title = "Epi Info™ Web Enter - Site Administration";// + " - "+ 
    // Model.SurveyName + " - " + Model.IsDraftModeStyleClass;
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="@Url.Content("~/Content/css/eweAdmin.css")" rel="Stylesheet" type="text/css" />
<script>
    $(document).ready(function () {
        $('#login-trigger').click(function () {
            $(this).next('#login-content').slideToggle();
            $(this).toggleClass('active');

            if ($(this).hasClass('active')) $(this).find('span').html('&#x25B2;')
            else $(this).find('span').html('&#x25BC;')
        })
    });
</script>
<div id="pageHeader" style="height: 31px; padding: 8px 0.5em 0 0;">
    <div id="pageTitleAdmin">
        @if (Model.UserHighestRole == 3)
        {
            <h2 class="adminnav">
                @Html.ActionLink("Organizations", "OrgList", "AdminOrganization", null, new { @class = "metro-tile metro-tile metro-design" })
            </h2>
            @*<h2 class="adminnav">@Html.ActionLink("Organizations", "OrgList", "AdminOrganization", null, new { @class = "orgbtn" })</h2>*@

        }
        <h2 class="adminnav">
            @Html.ActionLink("Users", "UserList", "AdminUser", null, new { @class = "metro-tile metro-tile metro-design metro-set" })
        </h2>
        @*<h2 class="adminnav">@Html.ActionLink("Users", "UserList", "AdminUser", null, new { @class = "userbtn" })</h2>*@
    </div>
    <script type="text/javascript">

        function GetList() {

            var element = document.getElementById("OrgList");
            var OrgId = element.options[element.selectedIndex].value;

            $("#UserList").show();
            $.ajax({
                url: '@Url.Action("GetUserList", "AdminUser")' + '?orgid=' + OrgId.toString(),
                type: 'GET',
                contentType: 'application/json; charset=utf-8',
                //data: JSON.stringify(model),
                success: successFunc,
                error: errorFunc
            });
            $.ajaxSetup({ cache: false });

            function successFunc(data, status) {

                $("#UserList").html(data);
                $("#success").hide();
            }

            function errorFunc() {
                alert('error');
            }
        }


    </script>
    <div id="userwelcome" style="margin-top:-42px !important;">
        <nav>
            <ul>
                <li id="login">
                    <a id="login-trigger" href="#">
                        @Session["UserFirstName"] <span>▼</span>
                    </a>
                    <div id="login-content">
                        @Html.ActionLink("Home", "Index", "Home", null, null) &nbsp; | &nbsp;
                        @Html.ActionLink("Log Out", "LogOut", "Home", null, null)

                    </div>
                </li>

            </ul>
        </nav>

    </div>
    <div style="clear: both;">
    </div>
</div>

<div id="content" style="margin: 15px 0 200px; padding-left: 10px; min-height: 375px;">
    <div id="formtitleadmin" style="display: none;">
        <h2 class="surveyTitle">
            Manage Users</h2>
    </div>
    <div style="clear: both;">
    </div>
    <div class="datagrid">
        @if (!string.IsNullOrEmpty(Model.Message))
        {
            <div id="success">
                <span>@Model.Message</span>
            </div>
        }
        <div style="clear: both;">
        </div>
        <div class="userorg">
            <label>
                <strong>Organization:</strong></label>
            <select id="OrgList" onchange="GetList()">
                @foreach (var Org in Model.OrgList)
                {
                    if (Org.OrganizationId == Convert.ToInt16(Session["CurrentOrgId"]))
                    {
                    <option value= '@Org.OrganizationId' selected>@Org.Organization</option>
                    }
                    else
                    {
                    <option value= '@Org.OrganizationId'>@Org.Organization</option>
                    }


                }
            </select>
        </div>
        <div id="adminpaging">
            <div style="float: right;">
                @Html.ActionLink("Add New User", "UserInfo", "AdminUser", new { userid = -1, iseditmode = false, orgid = ViewBag.SelectedOrg }, null)
            </div>
            @*<div style="float:right;">
			<a href="#"><span>Previous</span></a>
			<span>1 - 20 of 40</span></a>
			<a href="#"><span>Next</span></a>
		</div>*@
            <div style="clear: both;">
            </div>
        </div>
        <div style="clear: both;">
        </div>
        <div id="UserList">
            @Html.Partial("PartialUserList", Model.UserList)
        </div>
    </div>
    <div style="clear: both; visibility: collapse;">
    </div>
</div>
